/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package webproxy;

/**
 *
 * @author MinhVu
 */
public class HTTPResponse {
    private String Content_Type;
    private int Length;
    private String Last_Modified;
    private String Date;
    private int status;
    private String IP;
    
    //<editor-fold defaultstate="collapsed" desc="GET -SET">
    //GET
    public String getLast_Modified()
    {
        return Last_Modified;
    }
    public String getContent_Type()
    {
        return Content_Type;
    }
    public int getLength()
    {
        return Length;
    }
    public int getStatus()
    {
        return status;
    }
    public String getDate()
    {
        return Date;
    }
    public String getIP()
    {
         return IP;
    }
    //SET
    public void setLast_Modified(String d)
    {
         Last_Modified = d;
    }
    public void setDate(String d)
    {
        Date = d;
    }
    public void setContent_Typte(String ct)
    {
        Content_Type = ct;
    }
    public void setLength(int l)
    {
        Length = l;
    }
    public void setStatus(int s)
    {
        status =s;
    }
    public void setIP(String i)
    {
        IP = i;
    }
    //</editor-fold>
    
    public void PhanTichGoiTin(String data)
    { 
        String strLength =null;
        
            String strHeader[] = data.split("\r\n");
            for(int i = 0;i<strHeader.length;i++)
            {
                if(strHeader[i].indexOf("HTTP") !=-1)
                {
                    String Strstatus[] = strHeader[i].split(" ");
                    status =Integer.parseInt(Strstatus[1]);
                }
                if(strHeader[i].indexOf("Content-Type: ") !=-1) 
                    Content_Type  = strHeader[i].substring(14);
                if(strHeader[i].indexOf("Content-Length: ") !=-1) 
                    strLength = strHeader[i].substring(16);
                if(strHeader[i].indexOf("Last-Modified: ") !=-1)
                    Last_Modified=  strHeader[i].substring(15);
                if(strHeader[i].indexOf("Date: ") !=-1)
                    Date = strHeader[i].substring(5);
                if(strHeader[i].equals("")) 
                    break;
            }
        if(strLength !=null)
            Length = Integer.parseInt(strLength);
        else
            Length =0;
    }
    
}
